package com.example.ccj.b.c.dialog;

import android.content.Context;
import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.example.ccj.R;


public class ErrorDialog extends DialogBase{
    String value;
    String title;
    DialogButtonOnClickListener clickListener;
    public ErrorDialog(@NonNull Context context,String value) {
        super(context);
        this.value = value;
    }

    public ErrorDialog(@NonNull Context context,String value,Object... var) {
        super(context);
        for (Object o : var) {
            value = value.replaceFirst("[?]",o.toString());
        }
        this.value = value;
    }

    public ErrorDialog(@NonNull Context context,String title,String value,DialogButtonOnClickListener clickListener) {
        super(context);
        this.value = value;
        this.title = title;
        this.clickListener = clickListener;
    }

    @Override
    public void onInit() {
        setTitleCenterText("错误");
        setCenterText("错误："+value).setTextColor(Color.RED);
        setTitleLeftIcon(R.mipmap.def_dialog_error);
        setButtonSureText("确定").setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (clickListener != null) {
                    clickListener.dialogSure();
                }
            }
        });

    }
}
